package com.jie.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author: 杰
 * @Project :net-disk
 * @DateTime: 2024/5/29 16:17
 **/
public enum ArticleFlowEvent {
    REPLACE(1,"脱敏"),//脱敏
    AUDIT(2,"审核帖子"), //审核
    AUDIT_SUCCESS (3,"审核成功"),//发布成功
    AUDIT_FAIL(4,"审核帖子失败"),
    //发布帖子Publish
    PUBLISH(5,"发布帖子");
    private final Integer value;
    private final String desc;
    private static final Map<Integer,ArticleFlowEvent> valueMap=(Map) Arrays.stream(values()).collect(Collectors.toMap(ArticleFlowEvent::getValue, Function.identity()));

    ArticleFlowEvent(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
    public static ArticleFlowEvent fromValue(Integer value) {
        return (ArticleFlowEvent) Optional.ofNullable(valueMap.get(value)).orElseThrow(() -> {
            return new RuntimeException("can not find the enum for this value: " + value);
        });
    }
}
